/*
 * @Author: jiu yin
 * @Date: 2023-05-15 14:50:04
 * @LastEditTime: 2023-06-12 15:11:07
 * @LastEditors: jiu yin zhen jing
 * @FilePath: \AI admin\src\redux\modules\user.ts
 * jiu
 */
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import type { PayloadAction } from "@reduxjs/toolkit";


// 异步
export const asyncFn = createAsyncThunk("userFn", async (value: any) => {
   return Promise.resolve(value);
});

interface user{

}

export const user = createSlice({
   name: "user",
   initialState: {userInfo:{}},
   reducers: {
      set: (state, action: PayloadAction<user>) => {
        state.userInfo=action.payload
      },
   },
   //异步
   extraReducers: builder => {
      builder.addCase(asyncFn.fulfilled, (state, action) => {
         state.userInfo= action.payload; // 返回值
      });
   },
});

// Action creators are generated for each case reducer function
export const { set } = user.actions;

export default user.reducer;
